package com.foreveross.taskservice.common.model;

import java.text.SimpleDateFormat;
import java.util.Date;
/**
 * 任务时间戳
 * @author Administrator
 *
 */
public class TaskAction extends AbstractAction{
	
	public static final int TASK_ENTERWAITQUEUE=0;
	public static final int TASK_ENTERDOQUEUE=1;
	public static final int TASK_ROLLBACK=2;
	public static final int TASK_ENTERFINISHQUEUE=3;
	public static final int TASK_RELOADCOMPENSATION=4;
	public static final int TASK_TIMEOUT=5;
	
	public static final int TASK_FETCH=10;
	public static final int TASK_VALIDATE=11;
	public static final int TASK_PARASE=12;
	
	public static final int ERROR=20;
	
	/**
	 * 记录适配器中INFO级别消息轨迹
	 */
	public static final int TASK_INFO = 30;
	/**
	 * 记录适配器中ERROR级别消息轨迹
	 */
	public static final int TASK_ERROR = 31;
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -4636406626916132432L;

	public TaskAction(int actionType, long timestamp) {
		super(actionType, timestamp);
	}
	public TaskAction(int actionType, long timestamp, String remark) {
		super(actionType, timestamp,remark);
	}
	public TaskAction(int actionType, String dateStr, String remark){
		super(actionType, dateStr, remark);
	}
	
	public static TaskAction getEnterWaitQueueaAction(){
		return new TaskAction(TASK_ENTERWAITQUEUE,new Date().getTime(),"进入等待队列");
	} 
	public static TaskAction getEnterDoQueueAction(){
		return new TaskAction(TASK_ENTERDOQUEUE,new Date().getTime(),"进入执行队列");
	} 
	public static TaskAction getRollbackAction(){
		return new TaskAction(TASK_ROLLBACK,new Date().getTime(),"任务回滚");
	} 
	public static TaskAction getEnterFinishQueueAction(AbstractTaskModel model){
		return new TaskAction(TASK_ENTERFINISHQUEUE,new Date().getTime(),String.format("任务进入完成队列  当前任务状态[%s]", model.getStatus()));
	} 
	public static TaskAction getReloadCompensationAction(AbstractTaskModel model){
		return new TaskAction(TASK_ENTERFINISHQUEUE,new Date().getTime(),String.format("任务被重新载入补偿  当前任务状态[%s]", model.getStatus()));
	} 
	
	/**  
	 * @Description: 记录适配器info轨迹
	 * @param message
	 * @return
	 * @author luofangyi
	 * @date 2014-7-22 下午5:14:43 
	 */ 
	public static TaskAction getAdapterInfoAction(String message){
		return new TaskAction(TASK_INFO, new SimpleDateFormat("HH:mm:ss").format(new Date()), message);
	}	
	/**  
	 * @Description: 记录适配器error轨迹
	 * @param message
	 * @return
	 * @author luofangyi
	 * @date 2014-7-22 下午5:14:56 
	 */ 
	public static TaskAction getAdapterErrorAction(String message){
		return new TaskAction(TASK_ERROR, new SimpleDateFormat("HH:mm:ss").format(new Date()), message);
	}
}
